/**
 * Copyright (c) 2011 eelpo.com
 * All rights reserved.
 */
package com.eelpo.cmmp.uac.dao.vo.enumed;

import com.eelpo.common.util.BlankUtils;

/**
 * <pre>
 * 
 * IP过滤模式
 * 
 * </pre>
 * 
 * @author <a href="mailto:Brian@eelpo.com">汪洪州</a>
 * @since 1.0
 */
public enum FilterMode {

	/**
	 * 实例
	 */
	RANGEMATCH((byte) 0, "正向匹配"), REVERSEMATCH((byte) 1, "反向匹配"), ABSOLUTEMATCH((byte) 2, "绝对匹配"), ALL(null, "全部");

	/**
	 * 枚举值
	 */
	private Byte value;

	/**
	 * 枚举文本标签
	 */
	private String label;

	/**
	 * 构造函数，必须私有，不允许实例化
	 * 
	 * @param value
	 *            枚举值
	 * @param label
	 *            枚举文本标签
	 */
	private FilterMode(Byte value, String label) {
		this.value = value;
		this.label = label;
	}

	public Byte getValue() {
		return value;
	}

	public String getLabel() {
		return label;
	}

	public static FilterMode valueOf(byte value) {
		switch (value) {
		case 0:
			return RANGEMATCH;
		case 1:
			return REVERSEMATCH;
		default:
			return ABSOLUTEMATCH;
		}
	}

	public static Byte valueOf(FilterMode authMode) {
		if (BlankUtils.isBlank(authMode)) {
			return null;
		}

		return authMode.getValue();
	}
}
